<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <meta name="Generator" content="EditPlus®">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <title>Document</title>
 </head>
 <body>
		
 </body>
</html>
<script>
	//splice()截取数组
	var arr = ["东","西","南","北","中","发","白"];

	//传一个参数删除功能，从这个参数的下标（包含）后面所有的删除，返回删除的内容!改变就原数组
	var a = arr.splice(2);
	console.log(a);
	console.log(arr);

	//传二个参数删除功能, 第一个为下标(包含),第二个参数为要删除的个数,返回删除的内容，改变原数组
	var arr1 = ["东","西","南","北","中","发","白"];
	var b = arr1.splice(2, 4);
	console.log(b);
	console.log(arr1);

	//多个参数, 删除+替换,第一个为下标(包含),第二个参数为要删除的个数,第三个参以后为要替换的内容
	//返回删除的内容，改变原数组
	
	var arr2 = ["东","西","南","北","中","发","白"];
	var c = arr2.splice(2, 4, 'aa', 'bb', 'cc'); 
	console.log(c);
	console.log(arr2);

	//第四种情况：多个参数  添加  只是在某项后添加，不删除任何
	var arr3 = ["东","西","南","北","中","发","白"];
	var d = arr3.splice(2, 0, 'aa', 'bb', 'cc'); 
	console.log(d);
	console.log(arr3);

	//负数 删除倒数参数个数，返回删除的内容，改变原数组
	var arr4 = ["东","西","南","北","中","发","白"];
	var e = arr4.splice(-3);
	console.log(e);
	console.log(arr4);
</script>
